package com.richapp.launcher.scene.abstracts;

import android.util.Log;

import com.richapp.launcher.database.system.dao.UserMachineButtonDao;
import com.richapp.launcher.database.system.mode.UserMachineButton;
import com.richapp.launcher.scene.SceneServer;
import com.richapp.launcher.scene.interfaces.ISceneAction;
import com.richapp.launcher.scene.interfaces.ISceneInfrared;

/**
 * Created by jack on 2015/6/4 0004.
 */
public abstract class SceneAbstractInfraredAction implements ISceneAction,ISceneInfrared {

    private static final String TAG = SceneAbstractInfraredAction.class.getName();

    private String machineName;
    private int buttonId;
    private int delayActionTime = 1;
    private int orderNumber=0;

    @Override
    public void doDelay() {
        if(delayActionTime > 0){
            try {
                Thread.sleep(delayActionTime);
            } catch (InterruptedException e) {
                Log.e(TAG, e.getMessage());
            }
        }
    }

    @Override
    public UserMachineButton getMacineButton() {
        UserMachineButtonDao userMachineButtonDao = new UserMachineButtonDao(SceneServer.getInstance().getContext());
        return userMachineButtonDao.get(machineName,buttonId);
    }

    public String getMachineName() {
        return machineName;
    }

    public void setMachineName(String machineName) {
        this.machineName = machineName;
    }

    public int getButtonId() {
        return buttonId;
    }

    public void setButtonId(int buttonId) {
        this.buttonId = buttonId;
    }

    public int getDelayActionTime() {
        return delayActionTime;
    }

    public void setDelayActionTime(int delayActionTime) {
        this.delayActionTime = delayActionTime;
    }

    public int getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(int orderNumber) {
        this.orderNumber = orderNumber;
    }
}
